package com.kmdd.xtds.ui

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager
import com.kmdd.xtds.R
import com.kmdd.xtds.adapterOf
import com.kmdd.xtds.configs.Cover
import com.kmdd.xtds.configs.CoverConfigs
import com.kmdd.xtds.configs.PrefsManager
import com.kmdd.xtds.configs.UrlConfigs
import com.kmdd.xtds.databinding.FragmentFourBinding
import com.kmdd.xtds.databinding.FragmentSecondBinding
import com.kmdd.xtds.databinding.FragmentThirdBinding
import com.kmdd.xtds.databinding.ItemBloodRecordBinding
import com.kmdd.xtds.databinding.ItemNewsBinding
import com.kmdd.xtds.listAdapterOf
import com.kmdd.xtds.room.BloodPressureDatabase
import com.kmdd.xtds.room.BloodSugar
import com.kmdd.xtds.util.TimeUtil
import com.kmdd.xtds.util.TimeUtils
import com.kmdd.xtds.util.launch
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.withContext

/**
 * A simple [Fragment] subclass as the second destination in the navigation.
 */
class FourFragment : Fragment() {

    private var _binding: FragmentFourBinding? = null

    // This property is only valid between onCreateView and
    // onDestroyView.
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
    ): View {

        _binding = FragmentFourBinding.inflate(inflater, container, false)
        return binding.root

    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        binding.privacy.setOnClickListener {
            //隐私协议
            WebActivity.start(requireContext(), UrlConfigs.PRIVACY_URL)
        }

        binding.user.setOnClickListener {
            //用户协议
            WebActivity.start(requireContext(), UrlConfigs.USER_URL)
        }

        binding.feedback.setOnClickListener {
            FeedbackActivity.start(requireContext())
        }
    }
    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}